home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWPart / Include / FWExtMgr.h < prev    next >
Encoding:
Text File  |  1996-04-25  |  3.3 KB  |  107 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWExtMgr.h
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWEXTMGR_H
  11. #define FWEXTMGR_H
  12.  
  13. #include "FWTMap.tpp"
  14.  
  15. #ifndef FWEXCLIB_H
  16. #include "FWExcLib.h"
  17. #endif
  18.  
  19. #ifndef _ISOSTR_
  20. #include "ISOStr.h"
  21. #endif
  22.  
  23. //========================================================================================
  24. //    Globally Accessible Constants
  25. //========================================================================================
  26.  
  27. const FW_Boolean FW_kCacheWhenReleased = TRUE;
  28. const FW_Boolean FW_kDontCacheWhenReleased = FALSE;
  29.  
  30. const FW_Boolean FW_kCreateExtension = TRUE;
  31. const FW_Boolean FW_kDontCreateExtension = FALSE;
  32.  
  33. //========================================================================================
  34. //    Forward Declarations
  35. //========================================================================================
  36.  
  37. class ODExtension;
  38. class FW_CPart;
  39. struct FW_SPrivExtension;
  40.  
  41. typedef ODExtension* (*CreateExtensionFunc)(Environment* ev, FW_CPart* part, const char* name, void* refCon);
  42.  
  43. //========================================================================================
  44. //    struct FW_SPrivExtension
  45. //========================================================================================
  46.  
  47. struct FW_SPrivExtension
  48. {
  49.     FW_SPrivExtension() :
  50.         fCreateFunction(NULL), fRefCon(NULL), fExtension(NULL), fCacheWhenReleased(FALSE) {}
  51.     
  52.     FW_SPrivExtension(CreateExtensionFunc createFunc, void* refCon, FW_Boolean cacheWhenReleased) :
  53.         fCreateFunction(createFunc),
  54.         fRefCon(refCon),
  55.         fExtension(NULL),
  56.         fCacheWhenReleased(cacheWhenReleased) {}
  57.         
  58.     CreateExtensionFunc fCreateFunction;
  59.     void*                fRefCon;
  60.     ODExtension*        fExtension;
  61.     FW_Boolean            fCacheWhenReleased;
  62. };
  63.  
  64. typedef FW_TMap<const char*, FW_SPrivExtension> FW_CPrivNameToExtensionMap;
  65. typedef FW_TPair<const char*, FW_SPrivExtension> FW_CPrivNameToExtensionPair;
  66.  
  67. //========================================================================================
  68. //    class FW_CExtensionManager
  69. //========================================================================================
  70.  
  71. class FW_CExtensionManager
  72. {
  73. public:
  74.     FW_DECLARE_AUTO(FW_CExtensionManager)
  75.     
  76. public:
  77.  
  78.     ~FW_CExtensionManager();
  79.     FW_CExtensionManager(FW_CPart *part);
  80.     
  81.     void                     RegisterExtension(Environment* ev, 
  82.                                             const char* name, 
  83.                                             CreateExtensionFunc createFunc,
  84.                                             void* refCon,
  85.                                             FW_Boolean cacheWhenReleased);
  86.  
  87.     FW_Boolean                 HasExtension(Environment* ev, const char* name);
  88.  
  89.     ODExtension*             AcquireExtension(Environment* ev, const char* name, FW_Boolean allowCreation);
  90.                                 // acquire the named extension. If allowCreation is FALSE, the requested
  91.                                 // extension will be returned only if it exists and has a reference count
  92.                                 // greater than zero. If allowCreation is TRUE, the extension may be
  93.                                 // created to satisfy the request.
  94.  
  95.     FW_Boolean                 ReleaseExtension(Environment* ev, ODExtension* extension);
  96.  
  97.     void                    PurgeCachedExtensions(Environment* ev);
  98.  
  99.     void                    AbandonExtensions(Environment* ev);
  100.  
  101. private:
  102.     FW_CPart*                    fPart;
  103.     FW_CPrivNameToExtensionMap*    fNameToExtensionMap;
  104. };
  105.  
  106. #endif
  107.